package edu.gduf.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import edu.gduf.dto.SigninSystemResult;
import edu.gduf.service.StudentService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/student")
public class StudentController {
	@Autowired
	private StudentService studentService;

	@ApiOperation(value = "学生修改邮箱", notes = "")
	@ApiImplicitParams({ @ApiImplicitParam(name = "stuId", value = "学生学号", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "sEmail", value = "学生邮箱", required = true, dataType = "String") })
	@PostMapping("/updateEmail")
	public SigninSystemResult updateEmail(int stuId, String sEmail) {
		return studentService.updateEmail(stuId, sEmail);
	}

	@ApiOperation(value = "学生修改密码", notes = "")
	@ApiImplicitParams({ @ApiImplicitParam(name = "stuId", value = "学生", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "sPassword", value = "原学生密码", required = true, dataType = "String"),
			@ApiImplicitParam(name = "dPassword", value = "新学生密码", required = true, dataType = "String") })
	@PostMapping("/updatePassword")
	public SigninSystemResult updatePassword(int stuId, String sPassword, String dPassword) {
		return studentService.updatePassword(stuId, sPassword, dPassword);
	}
	
	
	@ApiOperation(value = "学生登录", notes = "")
	@ApiImplicitParams({ @ApiImplicitParam(name = "stuId", value = "学生学号", required = true, dataType = "Integer"),
			@ApiImplicitParam(name = "password", value = "学生密码", required = true, dataType = "String") })
	@PostMapping("/studentLogin")
	 public SigninSystemResult executeLogin(int stuId, String password) {
		return studentService.executeLogin(stuId,password);
	 }




}
